{% extends "./inc/base.html" %} {% block style %}
<!--<link rel="stylesheet" href="/static/admin/js/zTree/metroStyle/metroStyle.css" type="text/css">-->
<link rel="stylesheet" href="/static/admin/js/zTree/zTreeStyle/zTreeStyle.css" type="text/css">
 {% endblock%} {% block content %}
<section class="vbox">
    <section id="bjax-target">
        <section class="hbox stretch">
            <!-- side content -->
            {% include "./inc/article_side.html" %}
            <!-- / side content -->
            <section>
                <section class="vbox">
                    <section class="scrollable wrapper">
                        <!-- .breadcrumb -->
                        <ul class="breadcrumb">
                            <li><a href="/admin/article/index"><i class="fa fa-home"></i> 网站内容</a></li>
                            {% for nav in breadcrumb%} {% if cate_id == nav.id %}
                            <li class="active">{{nav.title}}  </li>
                            {%else%}
                            <li><a href="/admin/sp/index/?cate_id={{nav.id}}"><i class="fa fa-list-ul"></i> {{nav.title}}</a></li>
                            {% endif %} {% endfor %} {%if article.id >0 %}
                            <li> <i class="fa fa-list-ul"></i> {{article.title}} </li>{% endif %}
                        </ul>
                        <!-- / .breadcrumb -->
                        <section class="panel panel-default">
                            <header class="panel-heading text-right bg-light  clearfix">
                                <ul class="nav nav-tabs pull-left">
                                    <li class=""><a  href="/admin/sp/index/?cate_id={{controller.get('cate_id')}}">PC单页内容</a></li>
                                    <li class="active"><a  href="/admin/sp/mobile/?cate_id={{controller.get('cate_id')}}">手机单页内容</a></li>
                                </ul>
                                <span class="hidden-sm"><a href="/admin/category/index/?mold=2" class="text-info" target="_blank">栏目管理</a> | <a href="/sp/{{name}}" class="text-info" target="_blank">预览</a></span>
                            </header>
                            <div class="panel-body">
                        <form action="/admin/sp/update" class="form-horizontal" method="post"  data-validate="parsley">
                            <div class="tab-content">
                                <div id="tab3" class="tab-pane fade active in">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">选择类型</label>
                                        <div class="col-md-10">
                                            <label class="radio-inline i-checks ismt">
                                                <input type="radio"  value="0" name="ismt" {%if info.ismt ==0 or info.ismt ==null%}checked{%endif%}><i></i> 系统模板
                                            </label>
                                            <label class="radio-inline i-checks ismt">
                                                <input type="radio"  value="1" name="ismt" {%if info.ismt ==1%}checked{%endif%}><i></i> 独立模板
                                            </label>
                                            <label class="radio-inline i-checks ismt">
                                                <input type="radio"  value="2" name="ismt" {%if info.ismt ==2%}checked{%endif%}><i></i> 跳转链接
                                            </label>
                                        </div>
                                        <div class="col-md-12 hide">
                                            <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i>  。。。</span>
                                        </div>
                                    </div>

                                    <div class="line line-dashed b-b line-lg pull-in"></div>
                                    <div class="form-group sp_html_m" style="{%if info.ismt ==0 or info.ismt == null %}display: block{%else%}display: none{%endif%}">
                                        <div class="col-sm-12">
                                            <!-- 加载编辑器的容器 -->
                                            {{HOOKS@adminEdit@2_1.sp_html_m|safe}}
                                        </div>
                                    </div>
                                    <div class="form-group sp_temp_m" style="{%if info.ismt ==1%}display: block{%else%}display: none{%endif%}">
                                        <label class="col-sm-2 control-label">模板地址</label>
                                        <div class="col-sm-10">
                                            <div class="row">
                                                <div class="col-md-6"><input name="sp_temp_m"  type="text" value="{{info.sp_temp_m}}" class="form-control"></div>
                                                <div class="col-md-12">
                                                    <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 模板地址</span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group m_url" style="{%if info.ismt ==2%}display: block{%else%}display: none{%endif%}">
                                        <label class="col-sm-2 control-label">跳转地址</label>
                                        <div class="col-sm-10">
                                            <div class="row">
                                                <div class="col-md-6"><input name="m_url"  type="text" value="{{info.m_url}}" class="form-control"></div>
                                                <div class="col-md-12">
                                                    <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> http://baidu.com</span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </div>
                            <div class="form-group form-submit">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <input type="hidden" name="cid" value="{{controller.get('cate_id')}}">
                                    <button type="submit" target-form="form-horizontal" class="btn btn-primary ajax-post">保存</button>
                                    <button type="submit" class="btn btn-default" onclick="javascript:history.back(-1);return false;">返回</button>
                                </div>
                            </div>
                        </form>
                            </div>
                        </section>
                    </section>
                </section>
            </section>
        </section>
    </section>

</section>


{% endblock %} {% block script %}
<script src="/static/admin/js/zTree/jquery.ztree.core-3.5.min.js" type="text/javascript"></script>
<script src="/static/admin/js/parsley/parsley.min.js"></script>
<script src="/static/admin/js/parsley/parsley.extend.js"></script>
<script type="text/javascript">
    <!--
    var zTree;
    var demoIframe;

    var setting = {
        async: {
            enable: true,
            url: "/admin/article/getmenu",
        },
        view: {
            showLine: true,
            selectedMulti: false,
        },
        callback: {
            onAsyncSuccess: zTreeOnAsyncSuccess

        }
    };

    function zTreeOnAsyncSuccess(event, treeId, treeNode, msg) {
        // console.log(treeNode)
        var treeObj = $.fn.zTree.getZTreeObj(treeId);
        treeObj.expandAll(true);
        var id= $("#"+treeId).attr("data-cate");
        console.log(id);
        curMenu = treeObj.getNodeByParam("id", id, null);
        console.log(treeId)
        treeObj.selectNode(curMenu);
    };
    function expandNode(e) {
        var zTree = $.fn.zTree.getZTreeObj("tree"),
                type = e.data.type,
                nodes = zTree.getSelectedNodes();
        if (type == "expandAll") {
            zTree.expandAll(true);
        } else if (type == "collapseAll") {
            zTree.expandAll(false);
        }
    }


    //-->
    $(function(){
        //左边菜单
        var t = $("#tree");
        t = $.fn.zTree.init(t, setting).expandAll(true);
        $("#expandAllBtn").bind("click", {type:"expandAll"}, expandNode);
        $("#collapseAllBtn").bind("click", {type:"collapseAll"}, expandNode);
        //搜索功能
        $("#search").click(function(){
            var url = $(this).attr('url');
            var query  = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
            query = query.replace(/^&/g,'');
            if( url.indexOf('?')>0 ){
                url += '&' + query;
            }else{
                url += '?' + query;
            }
            window.location.href = url;
        });

        <!-- 实例化编辑器 -->
        $(".ismt").click(function () {
            var t =  $(this).find("input").val();
            switch (parseInt(t)){
                case 0:
                    $(".sp_html_m").show();
                    $(".sp_temp_m").hide();
                    $(".m_url").hide();
                    break;
                case 1:
                    $(".sp_html_m").hide();
                    $(".sp_temp_m").show();
                    $(".m_url").hide();
                    break;
                case 2:
                    $(".sp_html_m").hide();
                    $(".sp_temp_m").hide();
                    $(".m_url").show();
                    break;
            }

        })


    })
</script>



{% endblock %}}